import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;


public class a {

	/**
	 * @param args
	 */
	public static Connection connection;
	public static void Connect()
	{
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
			connection = null;
			connection = DriverManager.getConnection("jdbc:mysql://sql2.freemysqlhosting.net:3306/sql210820", "sql210820", "sE7!kE1!");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	public static String insertCommand(String TableName ,Vector<String> v)
	{
		String ans="INSERT INTO "+TableName+" VALUES (";
		for (int i = 0; i < v.size(); i++) {
			if(i+1<v.size())
			{
				ans+="'"+v.get(i)+"',";
			}
			else
			{
				ans+="'"+v.get(i)+"'";
			}
		}
		ans+=")";
		return ans;
	}
	public static String getAdminUserName() 
	{
		String ans="";
		try
		{
			Connect();
			Statement statement = connection.createStatement();
			String sql ="SELECT * FROM more";
			ResultSet resultSet = statement.executeQuery(sql); 
			ans=resultSet.getString(0);
			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return ans;
	}
	public static void initialize(String adminUsername, String pass) 
	{
		try
		{
			Connect();
			Statement statement = connection.createStatement();
			String sql ="DELETE FROM more";
			int resultSet = statement.executeUpdate(sql);
			statement = connection.createStatement();
			Vector<String> v=new Vector<String>();
			v.add(adminUsername);
			v.add(pass);
			sql = insertCommand("more", v);
			System.out.println(sql);
			resultSet = statement.executeUpdate(sql);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(getAdminUserName());
		
	}

}
